package com.share.slf4j.sample;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;

@Component
public class Slf4jsample implements CommandLineRunner{

    final Logger logger = LoggerFactory.getLogger(Slf4jsample.class);

    @Override
    public void run(String... args) throws Exception {
        System.out.println("test Hello, World!");
        while (true){
            logger.info("Start process...");
            try {
                "".getBytes("invalidCharsetName");
            } catch (UnsupportedEncodingException e) {
                logger.error("Invalid encoding.", e);
            }
            logger.warn("test warn level log.");
            logger.info("Process end.");
            logger.debug("test debug level log.");
//            try {
//                Thread.sleep(1 * 1);
//            } catch (InterruptedException e) {
//                logger.error("Thread interrupted.", e);
//            }
        }
    }
}
